import Vue from 'vue'
import Vuex from 'vuex'
import {getSongDetail, getSimiSong, getSongComment, getSongLyric, getSongUrl} from '../common/api.js'
Vue.use(Vuex)

export default new Vuex.Store({
	state:{
		topListIds:[],
		nextId:''
	},
	mutations:{
		// 拿到榜单的所有歌曲id
		INIT_TOPLISTIDS(state,payload){
			state.topListIds=payload
		},
		// 把当前歌曲的id传进去，得到下一首歌的id，从而能够连续播放
		NEXT_ID(state,payload){
			for(let i=0;i<state.topListIds.length;i++){
				if(state.topListIds[i].id===payload){
					state.nextId=state.topListIds[i+1].id
				}
			}
		}
	}
})